<include file='Common:head'/>
<div class="order_status">
	<div class="no_pay fl">未付款</div>
	<div class="pay_success fl">付款完成</div>
	<div class="all fl">全部</div>
	<div class="cl"></div>
</div>
<div class="box2">
	<input class="ordersnId" type="hidden" value=""> <!-- 当前处理订单号 -->
	<foreach name="list" item="vo" >
		<div class="receipt_goods md2">
			<div class="order_num">訂單號：{$vo.ordersn}</div>
			<div class="goods_img fl">
				<img src="{$vo.sa_address_img}"/>
				<!-- <empty name="vo.sa_address_img">
					<img src="{$vo.sa_weixin_avatar}"/>
				<else />
				</empty> -->
			</div>
			<div class="goods_info fl">
				<div class="title_left fl">{$vo.sa_address_name}</div>
				<div class="cash fr">￥{$vo.fact_price}</div>
				<div class="cl"></div>
				<div class="content">車牌：{$vo.license_plate}</div>
			</div>
			<div class="cl"></div>
		</div>
	<if condition="$vo.o_status eq 1">
		<!-- 已付款 -->
		<if condition="$vo.fact_price eq 0">
			<div class="ordersn_refund_status" ordersnid="{$vo.ordersn}">
				<div class="refund">已付款</div>
				<div class="cl"></div>
			</div>
		<else/>
			<if condition="$vo.wash_status gt 0">
				<div class="ordersn_refund_status" ordersnid="{$vo.ordersn}">
					<div class="refund">
						<switch name="vo.wash_status">
						<case value="1">清洗中</case>
	                    <case value="2">清洗完成</case>
					</switch>
					</div>
					<div class="cl"></div>
				</div>
			<else/>
				<div class="ordersn_refund" ordersnid="{$vo.ordersn}">
					<div class="refund">申請退款</div>
					<div class="cl"></div>
				</div>
			</if>
		</if>
	<else/>
		<!-- 订单状态 -->
		<div class="ordersn_refund_status" ordersnid="{$vo.ordersn}">
			<div class="refund">
				<switch name="vo.o_status">
					<case value="0">未付款</case>
					<case value="-1">退款審核中</case>
                    <case value="-2">退款審核成功</case>
                    <case value="-3">退款中</case>
                    <case value="-4">退款成功</case>
				    <default />退款不成功
				</switch>
			</div>
			<div class="cl"></div>
		</div>
	</if>

	</foreach>
</div>

<!-- 對話框 -->
<div id="fullbg"></div>
<div id="dialog" style="left:30%;">
<div class="select_washer close" style="font-size:2.8rem;">申請退款</div>
<div class="select_box">
		  <div class="washer" num='0'>
			<div style="font-size:2.8rem;text-align:left;">退款原因 :</div><br>
			<textarea class="reason" cols="30" rows="5" style="font-size: 2.5rem;"></textarea>
			<div class="cl"></div>
		  </div>
		</div>
		<div class="submit_wash">
		  	<div class="cancel fl" onclick="closeBg();" style="font-size:2.8rem;">取消</div>
		  	<div class="confirm fl" style="font-size:2.8rem;">確認申請</div>
		  	<div class="cl"></div>
		</div>
</div>
<!-- 對話框 -->

<script type="text/javascript">

// 确认按钮
$('.submit_wash .confirm').click(function(){
	//获取当前操作订单
	var ordersnId = $('.ordersnId').val(); $('.ordersnId').val('');//清空当前处理订单
	var reason 	  = $('.reason').val();	   $('.reason').val('');
	if ( ordersnId=='' || reason=='' ) {
		layer.open({
			style:'font-size:2.5rem;',
			content:'錯誤,請重新點擊退款',
			time:1.5,
			end:function(){
				closeBg();
	 		}
		});
		return false;
	}
	var data = {ordersnId : ordersnId,reason:reason};
	$.ajax({
		data : data,
		url : "{:U(MODULE_NAME.'/personal/application_refund')}",
		type:"post",
		dataType: "json",
		success: function (returndata) {
			if(returndata.status==1){
   		 		layer.open({
	 				style:'font-size:3rem;',
	 				content:returndata.info,
	 				time:2,
	 				end:function(){
						closeBg();
						window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/order_list',array('type'=>'pay_success'))}";
			 		}
 				});
   	 		}else{
				closeBg();
				window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/order_list',array('type'=>'pay_success'))}";
   	 		}
        }
	});
});

//调起确认提示框
$('.ordersn_refund .refund').click(function(){
	var bh = $("body").height();
	var bw = $("body").width();
	$("#fullbg").css({
		height:'100%',
		width:'100%',
		display:"block"
	});
	$("#dialog").show();

	var ordersnid = $(this).parent('.ordersn_refund').attr('ordersnid');
	$('.ordersnId').val(ordersnid);
});

//关闭灰色 jQuery 遮罩
function closeBg() {
	$("#fullbg,#dialog").hide();
}

$(document).ready(function(){
	$('title').html('個人中心');
	<if condition="$_GET['type'] eq 'no_pay'">
		$('.header .title').html('未付款訂單');
		$('.order_status .no_pay').css('color','#33CCFF');
	<elseif condition="$_GET['type'] eq 'pay_success'"/>
		$('.header .title').html('已付款訂單');
		$('.order_status .pay_success').css('color','#33CCFF');
	<else/>
		$('.header .title').html('全部訂單');
		$('.order_status .all').css('color','#33CCFF');
	</if>
	$('.order_status .no_pay').click(function(){
		window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/order_list',array('type'=>'no_pay'))}";
	});
	$('.order_status .pay_success').click(function(){
		 window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/order_list',array('type'=>'pay_success'))}";
	});
	$('.order_status .all').click(function(){
		window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/order_list',array('type'=>'all'))}";
	});

	$('.header .left').html('<img src="__PRIVATE__/images/left.png" style="width:55%"/>');
	$('.header .right').html('');
	$('.header .left').click(function(){
		window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/my')}";
	});
});

</script>
<include file='Common:footer'/>
